package com.scpii.api.service.content.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.scpii.api.domain.auth.UsersInfoDetails;
import com.scpii.api.domain.content.Activities;
import com.scpii.api.domain.user.UserActions.ActionType;
import com.scpii.api.persistence.content.ActivitiesMapper;
import com.scpii.api.service.content.ActivitiesService;
import com.scpii.api.util.PrincipalUtil;

@Service
public class ActivitiesServiceImpl implements ActivitiesService {

	@Resource
	private ActivitiesMapper activitiesMapper;

	@Override
	public List<Activities> selectBySelective(Activities record) {
		return activitiesMapper.selectBySelective(record);
	}

	@Override
	public void updateStatusByEndTime() {
		activitiesMapper.updateStatusByEndTime();
	}

	@Override
	public List<Activities> selectUsersActivities() {
		UsersInfoDetails usersInfoDetails = PrincipalUtil.getPrincipal();
		return activitiesMapper.selectUserActivitiesByUserIdAndActionTypes(
				usersInfoDetails.getId(), new String[] {
						ActionType.ACTIVITIES_JOIN.getValue(),
						ActionType.ACTIVITIES_FAV.getValue() });
	}
}
